#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-07-24 5:48 下午
# @Author  : yangdy
# @File    : Maximum Depth of N-ary Tree
# @Software: PyCharmCE
from typing import List
"""
# Definition for a Node.
class Node:
    def __init__(self, val=None, children=None):
        self.val = val
        self.children = children
"""


class Solution:
    def maxDepth(self, root: 'Node') -> int:
        ans = 0

        def dfs(rt: 'Node') -> int:
            if not rt:
                return 0
            m = 0
            for x in rt.children:
                m = max(m, dfs(x))
            return m + 1

        ans = dfs(root)
        return ans
